package cn.demoncat.test.neo.dao;

import cn.demoncat.test.neo.node.RUserNode;
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.repository.query.Param;

import java.util.List;

// DAO
// 文档： https://docs.spring.io/spring-data/neo4j/docs/5.3.3.RELEASE/reference/html/#neo4j.repositories
public interface RUserRepository extends Neo4jRepository<RUserNode, Long> {

    /**
     * JAP查询
     *
     * @Param 指定参数
     */
    List<RUserNode> findByName(@Param("name") String name);

    /**
     * Cypher查询
     *
     * @Query Cypher语法查询
     * @Param 指定参数
     */
    @Query("MATCH (user:RUser {name:$name}) RETURN user")
    RUserNode getUserByName(@Param("name") String name);


}
